<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/template.xhtml">
    <ui:define name="content">
    <h:form id="OrderSystemForm" align="center">
			<br />     
		<div align="center" style="width : 800px; font-size:11pt">
		<p:panel>
            <f:facet name="header" >
			<h3><h:outputText value="Create New Prescription Order" rendered="#{patientOrderBean.action == 'create'}"/></h3>
			<h3><h:outputText value="Update Existing Prescription Order" rendered="#{patientOrderBean.action == 'update'}"/></h3>
			<h3><h:outputText value="Delete Prescription Order" rendered="#{patientOrderBean.action == 'delete'}"/></h3>
			<h3><h:outputText value="View Prescription Order" rendered="#{patientOrderBean.action == 'view'}"/></h3>
            </f:facet>
            <br />
        	<h:outputText  value="Please enter prescription information below required field are marked with *" /><br/><br/>
    		<h:outputText value="Patient Order Id: "  />
    		<h:outputText value="#{patientOrderBean.patientOrderId}"  />
    		<br />
        		<h:panelGrid columns="5" style="margin-right:10px; cellspacing : 10pt">
        			
        			<h:outputText value="Patient Id: "  />
        			<p:inputText value="#{patientOrderBean.patientOrder.patientId}" required="false" readonly="true" styleClass="tb5" style="width: 50px;" />
        			<p:spacer width="30"/>
        			<h:outputText value="*First Name: "  />
        			<p:inputText value="#{patientOrderBean.patientOrder.patientFirstName}" required="true" readonly="true" styleClass="tb5" />
        			
        			
        			<h:outputText value="*Last Name: "  />
        			<p:inputText value="#{patientOrderBean.patientOrder.patientLastName}" required="true" readonly="true" styleClass="tb5"/>
        			<p:spacer width="30"/>
        			
        			<h:outputText value="Middle Initial: "  />
        			
        			<p:inputText value="#{patientOrderBean.patient.middleInitial}" required="false"  readonly="true" styleClass="tb5" style="width: 50px;" />
        			
        			
        			<h:outputText value="*Order Method: "  />
        			<p:inputText value="#{patientOrderBean.patientOrder.orderMethod}" required="false"  readonly="true" styleClass="tb5" style="width: 50px;" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        			<p:selectOneMenu  value="#{patientOrderBean.patientOrder.orderMethod}" required="true" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}" >
        				<f:selectItem itemValue="Called In" itemLabel="Called In" />
        				<f:selectItem itemValue="Walk In" itemLabel="Walk In" />
        			</p:selectOneMenu>
        		
        			<p:spacer width="30"/>
        			<h:outputText value="*Order Status: "  />
        			<p:inputText value="#{patientOrderBean.patientOrder.status}" required="false"  readonly="true" styleClass="tb5" style="width: 50px;" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        			<p:selectOneMenu  value="#{patientOrderBean.patientOrder.status}" required="true"  rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}">
        				<f:selectItem itemLabel="Open" itemValue="Open"/>
        				<f:selectItem  itemLabel="Closed" itemValue="Closed"/>
        				<f:selectItem  itemLabel="Prepared" itemValue="Prepared"/>
        				<f:selectItem itemLabel="Confirmed" itemValue="Confirmed"/>
        				<f:selectItem  itemLabel="Awaiting Confirmation" itemValue="Awaiting Confirmation"/>
        			</p:selectOneMenu>
        			<p:spacer /><h:messages />
        			<br />
        		</h:panelGrid>
        		</p:panel>
        		<p:panel>
        		<f:facet name="header">
        		<h:outputText value="Add Medications"  style="align : left"/>
        		</f:facet>
        		<h:panelGrid columns="3">
        		<h:outputText value="Medication Name" /><p:spacer width="30"/>
        		<h:outputText value="Quantity" />
        		
        		<p:autoComplete value="#{patientOrderBean.medication1}" completeMethod="#{patientOrderBean.autoComplete}" size="55" required="true" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}" />
        		<h:inputText value="#{patientOrderBean.medication1}"  readonly="true" size="55" required="true" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		<p:spacer width="30"/><h:inputText value="#{patientOrderBean.quantity1}" size="10" required="true" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}" />
        		<h:inputText value="#{patientOrderBean.quantity1}" size="10" readonly="true" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		
        		<p:autoComplete value="#{patientOrderBean.medication2}" completeMethod="#{patientOrderBean.autoComplete}" size="55" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}" />
        		<h:inputText value="#{patientOrderBean.medication2}"  readonly="true" size="55"  rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		<p:spacer width="30"/><h:inputText value="#{patientOrderBean.quantity2}" size="10" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}"/>
        		<h:inputText value="#{patientOrderBean.quantity2}" size="10" readonly="true" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		
        		<p:autoComplete value="#{patientOrderBean.medication3}" completeMethod="#{patientOrderBean.autoComplete}" size="55" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}" />
        		<h:inputText value="#{patientOrderBean.medication3}"  readonly="true" size="55"  rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		<p:spacer width="30"/><h:inputText value="#{patientOrderBean.quantity3}" size="10" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}"/>
        		<h:inputText value="#{patientOrderBean.quantity3}" size="10" readonly="true" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		
        		<p:autoComplete value="#{patientOrderBean.medication4}" completeMethod="#{patientOrderBean.autoComplete}" size="55" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}" />
        		<h:inputText value="#{patientOrderBean.medication4}"  readonly="true" size="55"  rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		<p:spacer width="30"/><h:inputText value="#{patientOrderBean.quantity4}" size="10" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}"/>
        		<h:inputText value="#{patientOrderBean.quantity4}" size="10" readonly="true" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		
        		<p:autoComplete value="#{patientOrderBean.medication5}" completeMethod="#{patientOrderBean.autoComplete}" size="55" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}" />
        		<h:inputText value="#{patientOrderBean.medication5}"  readonly="true" size="55"  rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		<p:spacer width="30"/><h:inputText value="#{patientOrderBean.quantity5}" size="10" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}"/>
        		<h:inputText value="#{patientOrderBean.quantity5}" size="10" readonly="true" rendered="#{patientOrderBean.action == 'find' || patientOrderBean.action == 'delete'}" />
        		
        		<h:messages />
        		</h:panelGrid>
        		<br />
        			<p:commandButton value="Reset" type="reset" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update'}"/>
        			
        			<p:commandButton value="Create" action="#{patientOrderBean.createPatientOrder}" onsuccess="if (#{patientOrderBean.message} == 'ordercreated') alert('Order Created, please click next to process')" rendered="#{patientOrderBean.action == 'create'}"/>
        			<p:commandButton value="Update" action="#{patientOrderBean.updatePatientOrder}" onsuccess="if (#{patientOrderBean.message} == 'orderupdates') alert('Order Updated, please click next to process')" rendered="#{patientOrderBean.action == 'update'}"/>
        			<p:commandButton value="Delete" action="#{patientOrderBean.deletePatientOrder}" onsuccess="if (#{patientOrderBean.message} == 'orderdeleted') alert('Order Deleted')" rendered="#{patientOrderBean.action == 'deleted'}"/>
        			
        			<p:commandButton value="Cancel" onclick="location.href='prescriptionhome.jsf'"/>
        			
        			<p:commandButton value="Next" action="#{patientOrderBean.next}" rendered="#{patientOrderBean.action == 'create' || patientOrderBean.action == 'update' || patientOrderBean.action == 'find'}"/>
    		</p:panel>   		
		</div>
		</h:form>

    </ui:define>
</ui:composition>
